﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MetaSharp.Transformation
{
    public interface ITransformer
    {
        Task<TransformResult> Transform(TransformationContext context);
    }

    public class TransformationContext
    {
        System.IO.Stream content;
        string language;
        string configuration;
        public TransformationContext(System.IO.Stream content, string language, string configuration)
        {
            this.content = content;
            this.language = language;
            this.configuration = configuration;
        }

        public System.IO.Stream Content
        {
            get { return this.content; }
        }

        public string Language
        {
            get { return this.language; }
        }

        public string Configuration
        {
            get { return this.configuration; }
        }
    }

    public enum TransformResultKind
    {
        None,
        Compile,
        Content,
    }

    public class TransformResult
    {
        IEnumerable<TransformOutput> output;
        IEnumerable<Error> errors;
        public TransformResult(IEnumerable<TransformOutput> output, IEnumerable<Error> errors)
        {
            this.output = output;
            this.errors = errors;
        }

        public IEnumerable<TransformOutput> Output
        {
            get { return this.output; }
        }

        public IEnumerable<Error> Errors
        {
            get { return this.errors; }
        }

    }

    public class TransformOutput
    {
        byte[] data;
        string extension;
        TransformResultKind kind;
        public TransformOutput(byte[] data, string extension, TransformResultKind kind)
        {
            this.data = data;
            this.extension = extension;
            this.kind = kind;
        }

        public byte[] Data
        {
            get { return this.data; }
        }

        public TransformResultKind Kind
        {
            get { return this.kind; }
        }

        public string Extension
        {
            get { return this.extension; }
        }
    }
}
